// @ts-ignore
/* eslint-disable */
import request from '@/request'

/** deleteFile POST /api/file/delete */
export async function deleteFileUsingPost(
  body: API.DeleteRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/file/delete', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** editFile POST /api/file/edit */
export async function editFileUsingPost(
  body: API.FileEditRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/file/edit', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** getFileById GET /api/file/get */
export async function getFileByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getFileByIdUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseFile_>('/api/file/get', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** getFileVOById GET /api/file/get/vo */
export async function getFileVoByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getFileVOByIdUsingGETParams,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseFileVO_>('/api/file/get/vo', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  })
}

/** listFileByPage POST /api/file/list/page */
export async function listFileByPageUsingPost(
  body: API.FileQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageFile_>('/api/file/list/page', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** listFileMyByPage POST /api/file/list/page/my */
export async function listFileMyByPageUsingPost(
  body: API.FileQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageFileVO_>('/api/file/list/page/my', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** listFileVOByPage POST /api/file/list/page/vo */
export async function listFileVoByPageUsingPost(
  body: API.FileQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageFileVO_>('/api/file/list/page/vo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** listFileTagCategory GET /api/file/tag_category */
export async function listFileTagCategoryUsingGet(options?: { [key: string]: any }) {
  return request<API.BaseResponseFileTagCategory_>('/api/file/tag_category', {
    method: 'GET',
    ...(options || {}),
  })
}

/** updateFile POST /api/file/update */
export async function updateFileUsingPost(
  body: API.FileUpdateRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>('/api/file/update', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** uploadFile POST /api/file/upload */
export async function uploadFileUsingPost(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.uploadFileUsingPOSTParams,
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<API.BaseResponseFileVO_>('/api/file/upload', {
    method: 'POST',
    params: {
      ...params,
    },
    data: formData,
    requestType: 'form',
    ...(options || {}),
  })
}
